import { defineStore } from "pinia";
import {ref} from 'vue'

export const useUserStore = defineStore('user',() => {
    const isLoggedIn = ref(false)
    const username = ref('')
    const role = ref('') //'student' or 'teacher'

    const login = (user) => {
        isLoggedIn.value = true
        username.value = user.username
        role.value = user.role
    }

    const logout = () => {
        isLoggedIn.value = false
        username.value = ''
        role.value = ''
    }

    return {isLoggedIn,username,role,login,logout}
})